package td0.shape;

import td0.shape.Shape2D;

public final class Point extends Shape2D {

	private int x;
	private int y;

	/**
	 * Constructeur
	 * 
	 * @param name
	 * @param x
	 * @param y
	 */
	public Point(int x, int y) {
		super("Point");
		this.x = x;
		this.y = y;
	}

	@Override
	public double perimeter() {
		return 0d;
	}

	@Override
	public double surface() {
		return 0d;
	}

	public boolean isOrigin() {
		return true;
	}

	/**
	 * Calcule la distance entre deux points
	 * 
	 * @param p
	 * @return la distance
	 */
	public double distance(Point p) {
		return Math.sqrt(Math.pow(p.getX() - this.getX(), 2)
				+ Math.pow(p.getY() - this.getY(), 2));
	}

	public void translate(int dx, int dy) {
		this.x += dx;
		this.y += dy;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	@Override
	public String toString() {
		return getName() + " [x=" + x + ", y=" + y + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		if (obj == this)
			return true;

		if (!this.getClass().equals(obj.getClass()))
			return false;

		Point p = (Point) obj;
		return p.x == this.x && p.y == this.y;
	}
	

	
}
